package org.example.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
public class FunctionCallApiController {

    private final ChatClient chatClient;


    @GetMapping("/ai/funcCall")
    public String funcCall(@RequestParam("message") String message) {
        ChatClient.CallResponseSpec askForLeave = chatClient.prompt(message)
                .functions("askForLeave", "fiveCode")
                .call();
        String content = askForLeave.content();
        ChatResponse chatResponse = askForLeave.chatResponse();
        return content;
    }
}
